home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ahoy 1989 February
/
Ahoy_Magazine_89-02_1989_Double_L.d64
/
Charitable Task
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-10-26
|
632b
|
16 lines
0 print"[147]"tab(12)"charitable task"
1 rem ==================================
2 rem commodares problem #58-3 :
3 rem charitable task
4 rem solution by
5 rem keith kushner
6 rem ==================================
10 zz=rnd(-ti):d=3e3:fort=0to8:a(t)=int(rnd(1)*900+100):next
20 foru=1to7:forv=u+1to8:fort=0to8:b(t)=a(t):next
30 b(u)=a(1):b(v)=a(2+(u=2)):b(1)=a(u):b(2)=a(v):gosub80:gosub50:gosub40:next:next:end
40 forx=3to5:fory=6to8:gosub80:c(x)=b(y):c(y)=b(x):gosub50:next:next:return
50 h=0:l=3e3:fort=0to2:s(t)=c(3*t)+c(3*t+1)+c(3*t+2)
60 h=h-(s(t)-h)*(s(t)>h):l=l+(l-s(t))*(s(t)<l):next:on-(h-l<d)gosub70:return
70 d=h-l:fort=0to2:forw=0to2:printc(w+3*t);:next:print"=";s(t):next:printd:return
80 fort=0to8:c(t)=b(t):nextt:return